package org.dromara.solonplugins.job.test2.config;

import org.dromara.solonplugins.job.CustomThreadFactory;
import org.dromara.solonplugins.job.impl.JobExecutor;
import org.dromara.solonplugins.job.test2.service.JobLogService;
import org.noear.solon.annotation.Bean;
import org.noear.solon.annotation.Configuration;
import org.noear.solon.annotation.Inject;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * Job配置
 *
 * @author: aoshiguchen
 */
@Configuration
public class JobConfiguration {

    @Bean
    private void jobExecutor(@Inject JobLogService jobLogService, @Inject JobExecutor jobExecutor) {
        jobExecutor.setJobCallback(jobLogService);
        jobExecutor.setThreadPoolExecutor(new ThreadPoolExecutor(1, 5, 10L, TimeUnit.SECONDS,
                new LinkedBlockingQueue<>(), new CustomThreadFactory("TestPool")));
    }

}
